Skip to content

Allow fixture and marker listing without required plugin options - #15158

Closed
Sagar07-star wants to merge 3 commits into
pytest-dev:mainfrom
Sagar07-star:fix/3042-information-required-options
Closed

Sagar07-star wants to merge 3 commits into
pytest-dev:mainfrom
Sagar07-star:fix/3042-information-required-options

Conversation

@Sagar07-star

Copy link
Copy Markdown

Temporarily relax required options for informational actions and restore them after parsing. Add regression tests for listing commands, normal runs, parser reuse, invalid values, option termination, and argument files.

Fixes #3042

Temporarily relax required options for informational actions and restore them after parsing. Add regression tests for listing commands, normal runs, parser reuse, invalid values, option termination, and argument files.

Fixes pytest-dev#3042
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 10, 2026

Copy link
Copy Markdown
Member

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

Closing this. It's a half-done fix for the wrong problem.

Flipping required = False on every parser action whenever --fixtures/--markers shows up doesn't make those modes work. It just moves the failure. Plugins that declared an option required=True now get None for it, so a conftest whose pytest_configure uses the value (e.g. config.getoption("server").split(":")) goes from a clean usage error to an INTERNALERROR ... AttributeError: 'NoneType' under pytest --fixtures. The change also mutates shared argparse state from inside an action, relies on when argparse checks required internally, and has an untested pre-relax branch that has no effect (with it disabled, all of the new tests still pass).

The direction for #3042 is to deprecate required=True for pytest options and document checking for missing values in a hook and raising pytest.UsageError, so informational modes keep working. We'll follow up with a PR for that.

Thanks for the effort anyway.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--fixtures and --markers are broken when there's a required option added in pytest_addoption()

2 participants